<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
  
</head>
<body>
    



    <div id="mydiv" style="width: 300px;height: 300px;border: solid 1px red;"  >



    </div>



    
    <script>
        //找到div
        let div = document.querySelector("#mydiv");
        // console.log("div",div)

        //添加事件
        div.addEventListener('mouseenter',function(event){
            const x = event.clientX;
            const y = event.clientY;
            console.log("进入",x,y)
        })

        //添加事件
        div.addEventListener('mouseleave',function(event){
            const x = event.clientX;
            const y = event.clientY;
            console.log("离开",x,y)
        })

    </script>


</body>
</html>